home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq15.zip
/
MAILUP.SLT
< prev
next >
Wrap
Text File
|
1991-02-02
|
27KB
|
739 lines
//-----------------------------------------------------------
// MAILUP.SL? Automatic ASCII upload.
//
// Please look at the comments through the whole file, and modify to
// suit your needs, BEFORE you use it. Then recompile with CS MAILUP.
// Note: Lines commented out with //!! are not used in this script,
// but in other, related ones. Please don't delete them; they may
// become useful later.
//-----------------------------------------------------------
int LIMIT = 999; // Max. no. of lines for messages.
str bbs_type [32] // BBS type.
,codename [8] // This BBS's codename
,maildir [64] = "" // Mail directory
,input [144] // Input line.
,input1 [144] // Help line.
,filespec [64] // File specification.
,shortname [10] // Shortened name for this BBS.
,PrevConf [20] // Previous conference.
,file [64] // Filename for upload.
,allfiles [100] // File *numbers* for upload.
,command [10]="Command:" // Command prompt.
,temp [4] // Short temporary string.
// For the Global storage:
,global []="GLOBAL" // Global script.
,join []="JOINCONF" // Join Conference script
,bbstype []="BTYPE" // BBS type.
,short []="SHORT" // Short BBS name.
,code []="CNAME" // Codename for this BBS.
,graph []="GRAPH" // Graphics
,version []="PCBVER" // PCB version number
,conf []="CONF" // Current conference.
,prompt []="PROMPT" // Current command prompt.
;
int tol = 300 // No activity for 30 sec.
,stat, tmark // makes script time out.
,mbbs, pcb, rbbs, opus, fido, crcs
,PCBver // PCBoard version.
,first
,graphics
;
//-----------------------------------------------------------
// Script starts here.
//-----------------------------------------------------------
main()
{
int c, i, j, k, l, m;
update_term(); // Update status bar.
// Only if online.
if (!carrier())
{ failtone();
status_wind ("THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
return (-1);
}
read (bbstype,bbs_type); // Get BBS type.
read (short,shortname); // Shortened BBS name.
read (conf,PrevConf); // Previous conference.
read (prompt,command); // Command prompt.
mbbs = pcb = rbbs = opus = fido = crcs = 0;
if (bbs_type == "MBBS") mbbs = 1;
else if (bbs_type == "PCB" )
{ pcb = 1;
read (version,temp);
PCBver = stoi (temp); // Get PCB version.
}
else if (bbs_type == "RBBS") rbbs = 1;
else if (bbs_type == "OPUS") opus = 1;
else if (bbs_type == "FIDO") fido = 1;
else if (bbs_type == "CRCS") crcs = 1;
else
{ wrongBBS(); // Doesn't match script!
return (-1);
}
// Search for the upload specifications.
if (read (code,codename) <= 0) // Get BBS ID-code.
codename = "MAIL"; // Set default.
if (getenv ("XBOARD",maildir)) // Get XBoard dir.
get_id_code(); // Get correct ID-code.
else if (m=fopen("XBOARD.DIR","r") >0) // Try open XBoard.DIR file.
{ fgets (maildir,64,m); // Read dir.name.
fclose (m);
get_id_code();
}
else
maildir = _up_dir; // If no XBoard, use MailDir.
if (codename=="MAIL")
strcat (maildir,shortname); // Use short name.
else
strcat (maildir,codename); // Use codename.
strcat (maildir,"\");
filespec = maildir; // Get mail dir.
strcat (filespec,codename); // Add codename again.
strcat (filespec,".m*"); // Add extension.
setchrs (allfiles,0,' ',100); // Init. all files to 0.
while (filefind(filespec,0,file)) // For each file found:
{ filespec = "";
k = strposi (file,".M",0); // Find number.
setchrs(file,0,' ',k+2);
setchr (allfiles,stoi(file),'!'); // Mark this file number.
}
while ((k=strposi(allfiles,"!",0)) > 0)// For each file found
{ setchr (allfiles,k,' '); // earlier:
itos (k,file);
filespec=codename; // Build name.
strcat(filespec,".M");
strcat(filespec,file);
message_up(filespec); // Send message.
}
return(0);
}
//-----------------------------------------------------------
// Upload one message to the BBS.
//-----------------------------------------------------------
message_up (str fname)
{
int f, i, l, lineno, FSE, again // File handle etc.
,RO, WT
,t1, t2, t3, t4, t5, t6, t7, t8, t11 // Variables for tracking.
,SendOK
,empty, hide, number
;
str fullname [64] // Full file name.
,include [64] // Include file name.
,conf [20] // Conference name.
,towhom [24] // To whom.
,reply [6] // Reply to which mess.number
,subj [26] // What subject?
,echo [4] // Echo to other BBSes?
,priv [4] // Private?
,help [6] // Help string
,sline [80] // Line read back from screen.
,quote [4] // Previous
,nextq [4] // and next quote.
;
fullname = maildir; // Build full filename.
strcat(fullname,fname);
f=fopen(fullname,"r"); // Open file,
if (f < 0) return (0); // check for error.
// Read these before starting to send mail.
if (fgets(input,144,f) <0) goto error; // Read conference.
conf = input;
if (fgets(input,144,f) <0) goto error; // Read name.
towhom = input;
if (fgets(input,144,f) <0) goto error; // Read reference
reply = input;
if (fgets(input,144,f) <0) goto error; // Read subject.
subj = input;
if (fgets(input,144,f) <0) goto error; // Echo to other systems (Yes/no)
echo = input;
strcat (echo,"^M"); // Add a CR.
if (fgets(input,144,f) <0) goto error; // Read private (Yes/no)
priv = input;
goto OK;
error:
fclose(f);
fdelete (fullname);
return (0);
OK:
if (subchr(echo,0)=='Y') // Answer to echo question
echo = "y^M"; // must be Y
else // or
echo = "n^M"; // N.
if (subchr(priv,0)=='Y') // Private?
RO = 1; // Yes
else // or
RO = 0; // No.
if (call (Join,conf) < 0) // Join conference.
return (0); // Return if error.
again = 0;
// Send the mail. Maildir contains directory, Filespec contains
// wildcard name of the files to be uploaded.
enter: // Start entering message.
WT = 1; // Wait time initially 1 sec.
if (reply == "0")
{ cputs("e ");
if (pcb) // PCBoard won't have
{ cputs ("^M"); // the name on the
help = ":";
if (PCBver>144) help="`ALL'?";
if (!waitfor (help,WT))
++WT; // same line!
else if (WT > 2)
--WT;
}
cputs(towhom);
}
else
{ cputs("reply "); // Answer to previous message.
cputs(reply);
}
cputs(